package com.ycx.ycxmybatismanagement.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Slf4j
@Aspect
//@Component
public class MyAspect {
    /**
     *
     * @param
     * @return  around before
     *          before
     *          after Retrning
     *          after
     *          around after
     * @throws Throwable
     */
    @Pointcut("execution(* com.ycx.ycxmybatismanagement.service.Impl.*.*(..))")
    public void pc(){}
    @Around("pc()") //切点表达式:作用到什么上  +通知  = 切面
    public Object recordTime(ProceedingJoinPoint pjp) throws Throwable {
        log.info("around before");
        Object result = pjp.proceed();
        log.info("around after");
        return result;
    }
    @Before("pc()")
    public void before(){
        log.info("before");
    }
    @After("pc()")
    public void After() throws Throwable {
        log.info("After");
    }

    @AfterReturning("pc()")
    public void AfterReturning() throws Throwable {
        log.info("AfterReturning");
    }

    @AfterThrowing("pc()")
    public void AfterThrowing() throws Throwable {
        log.info("AfterThrowing");
    }

}
